<template>
    <div id="tixianPage">
      <el-row style="padding: 10px;text-align: left">

        <el-dialog title="提现" :visible.sync="dialogVisible" size="tiny">
          <el-form :model="form">
            <el-form-item label="提现金额" :label-width="formLabelWidth">
              <el-input v-model="form.money" auto-complete="off"></el-input>
            </el-form-item>

          </el-form>
          <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="tixian">确 定</el-button>
  </span>
        </el-dialog>
      </el-row>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="index" width="80">
        </el-table-column>
        <el-table-column prop="cardBank" label="银行名称">
        </el-table-column>
        <el-table-column prop="cardNo" label="银行卡号" >
        </el-table-column>
        <el-table-column prop="cardPerson" label="持卡人姓名">
        </el-table-column>
        <el-table-column prop="balance" label="余额" width="120">
        </el-table-column>
        <el-table-column label="提现(银行卡)">
          <template slot-scope="scope">
            <el-button type="text" @click="changeStatus(scope.row.id)">提现</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="text-align: right;padding-right: 40px;">

        <el-pagination :current-page.sync="pageNumber" @current-change='handleChange' :page="pageNumber" :page-size="pageSize" layout="total, prev, pager, next" :total="total">
        </el-pagination>
      </div>
    </div>
</template>

<script>
    export default {
        data () {
            return {
              tableData: [],
              pageSize:10,
              pageNumber:1,
              total:1,
              dialogVisible:false,
              formLabelWidth:'80px',
              form:{
                money:0
              }
            }
        },
      created(){
          this.getTixianList()
      },
        methods: {
          getTixianList(){
              this.$api.getCashBankList().then(res=>{
                if (res.code == '000000'){
                  this.tableData = res.data;
                  this.$message.success("获取用户银行卡列表成功")
                }

              })
          },
          changeStatus(id){
            this.dialogVisible = true;
            sessionStorage.setItem("businessCardId",id)
          },
          tixian(){
            let params ={
              type:2,
              total:this.form.money,
              businessCardId:sessionStorage.getItem("businessCardId")
            }
            this.dialogVisible = false;
             this.$api.requireCash(params).then(res=>{
               this.$message.success("提现成功")
             })
          },
          handleChange(val){
            this.pageNumber = val;
            this.getTixianList()
          }
        }


    }
</script>

<style lang="less">
  #tixianPage{
    th{
      text-align: center;
    }
  }
</style>
